<template>
  <div>
    <details v-for="(item, index) in node" :key="index">
      <summary>{{ item.title }}</summary>
      <div class="content" v-if="item.content">{{ item.content }}</div>
      <div v-if="item.children && item.children.length > 0">
        <nested-details :node="item.children" />
      </div>
    </details>
  </div>
</template>

<script>
export default {
  name: 'NestedDetails',
  props: {
    node: {
      type: Array,
      required: true,
      default: () => []
    }
  },
  components: {
    NestedDetails: () => import('./NestedDetails.vue')
  }
}
</script>

<style lang="scss" scoped>
details {
  padding-left: 20px;
  & > .content {
    padding: 6px 25px;
    font-size: 14px;
    color: #4e4d4d;
  }
}
summary {
  display: flex;
  align-items: center;
  // padding-left: 10px;
}
summary:not(:only-child):before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-right: 8px;
  border: 1px solid #999;
  background: linear-gradient(#999, #999) 50%/1px 10px no-repeat,
    linear-gradient(#999, #999) 50%/10px 1px no-repeat;
}
details[open] > summary::before {
  background: linear-gradient(#999, #999) 50%/10px 1px no-repeat;
}
</style>
